package com.sfx.算法专题.位运算;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-08-21
 * Time: 9:05
 */
public class Code_3_hammingDistance {
    static class Solution {
        public int hammingDistance(int x, int y) {
            int res = 0;
            for(int i =0;i<32;++i) {
                if((x & 1) != (y&1)) {
                    res ++;
                }
                x >>= 1;
                y >>= 1;
            }
            return res;
        }
    }
}